|
|
|
|
|
|
|
Figure 10.25
Depth one, two, and three Peano curves. |
|
|
|
 |
|
|
|
|
' Draw a Peano curve. Private Sub Peano(ByVal depth As Integer, _
ByVal dx As Single, ByVal dy As Single)
Dim dx3 As Single
Dim dy3 As Single
If depth > 0 Then
dx3 = dx / 3
dy3 = dy / 3
Peano depth - 1, dx3, dy3
Peano depth - 1, dy3, dx3
Peano depth - 1, dx3, dy3
Peano depth - 1, -dy3, -dx3
Peano depth - 1, -dx3, -dy3
Peano depth - 1, -dy3, -dx3
Peano depth - 1, dx3, dy3
Peano depth - 1, dy3, dx3
Peano depth - 1, dx3, dy3
Else
picCanvas.Line -Step(dx, dy)
End If
End Sub |
|
|
|
|
|
|
|
|
You can think of a fractal gasket as a geometric shape with some holes cut in it. The gasket shown in Figure 10.26 is called the Sierpinski gasket. The simplest way to create a Sierpinski gasket is to draw a large filled triangle. Break the triangle into four smaller triangles and erase the middle one. Then recursively call a subroutine to erase the middle triangles from the three remaining triangles. |
|
|
|
|
|
|
|
|
The following source code uses this method to draw Sierpinski gaskets. |
|
|
|
 |
|
|
|
|
Private Type POINTAPI
X As Long |
|
|
|
|
|